const sequelize = require("./db");
const { DataTypes } = require("sequelize");

const AdSpace = sequelize.define("AdSpace", {
  name: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  type:{
    type:DataTypes.INTEGER,
  },
  ads: {
    type: DataTypes.TEXT,
    allowNull:false,
    get(){
      return JSON.parse(this.getDataValue('ads'))
    },
    set(value){
      return this.setDataValue('ads',JSON.stringify(value))
    }
  },

});

module.exports = AdSpace;
